<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android,IPC," />





  <link rel="alternate" href="/atom.xml" title="GrantonZhuang's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="AIDL 是 Android 中非常常见的一个跨进程通信机制，常规的 AIDL 用法是建立一个 Service，重写 onBind 方法返回对应的 IBinder 对象，作为 Android 的四大组件之一，Service 在运行的时候，会单独作为一个条目，出现在系统的应用程序列表中。
如果我们有多个业务需要用到 AIDL，在系统的程序列表中会出现一大堆的后台服务，这显然不是好事，这时候我们需要">
<meta property="og:type" content="article">
<meta property="og:title" content="Android IPC 学习笔记 4 Binder 连接池">
<meta property="og:url" content="https://grantonzhuang.github.io/2016/07/01/AndroidIPC学习笔记4/index.html">
<meta property="og:site_name" content="GrantonZhuang's Blog">
<meta property="og:description" content="AIDL 是 Android 中非常常见的一个跨进程通信机制，常规的 AIDL 用法是建立一个 Service，重写 onBind 方法返回对应的 IBinder 对象，作为 Android 的四大组件之一，Service 在运行的时候，会单独作为一个条目，出现在系统的应用程序列表中。
如果我们有多个业务需要用到 AIDL，在系统的程序列表中会出现一大堆的后台服务，这显然不是好事，这时候我们需要">
<meta property="og:updated_time" content="2016-07-29T13:56:02.584Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android IPC 学习笔记 4 Binder 连接池">
<meta name="twitter:description" content="AIDL 是 Android 中非常常见的一个跨进程通信机制，常规的 AIDL 用法是建立一个 Service，重写 onBind 方法返回对应的 IBinder 对象，作为 Android 的四大组件之一，Service 在运行的时候，会单独作为一个条目，出现在系统的应用程序列表中。
如果我们有多个业务需要用到 AIDL，在系统的程序列表中会出现一大堆的后台服务，这显然不是好事，这时候我们需要">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="https://grantonzhuang.github.io/2016/07/01/AndroidIPC学习笔记4/"/>

  <title> Android IPC 学习笔记 4 Binder 连接池 | GrantonZhuang's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">GrantonZhuang's Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Android IPC 学习笔记 4 Binder 连接池
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-07-01T21:27:13+08:00" content="2016-07-01">
              2016-07-01
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>AIDL 是 Android 中非常常见的一个跨进程通信机制，常规的 AIDL 用法是建立一个 Service，重写 <code>onBind</code> 方法返回对应的 <code>IBinder</code> 对象，作为 Android 的四大组件之一，Service 在运行的时候，会单独作为一个条目，出现在系统的应用程序列表中。</p>
<p>如果我们有多个业务需要用到 AIDL，在系统的程序列表中会出现一大堆的后台服务，这显然不是好事，这时候我们需要 Binder 连接池来帮助我们统一管理多个业务的 AIDL，使用这种方案，只需要一个 Service。</p>
<a id="more"></a>
<h2 id="建立不同业务的-AIDL-接口"><a href="#建立不同业务的-AIDL-接口" class="headerlink" title="建立不同业务的 AIDL 接口"></a>建立不同业务的 AIDL 接口</h2><ul>
<li><code>ICompute.aidl</code></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> us.igrant.binderconnectpool;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">interface</span> <span class="title">ICompute</span> </span>&#123;</div><div class="line">    <span class="function"><span class="keyword">int</span> <span class="title">add</span><span class="params">(<span class="keyword">int</span> a, <span class="keyword">int</span> b)</span></span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li><code>ISecurityCenter.aidl</code></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> us.igrant.binderconnectpool;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">interface</span> <span class="title">ISecurityCenter</span> </span>&#123;</div><div class="line">    <span class="function">String <span class="title">encrypt</span><span class="params">(String content)</span></span>;</div><div class="line">    <span class="function">String <span class="title">decrypt</span><span class="params">(String password)</span></span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="接口的实现"><a href="#接口的实现" class="headerlink" title="接口的实现"></a>接口的实现</h2><ul>
<li><code>ComputeImpl.java</code></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> us.igrant.binderconnectpool;</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ComputeImpl</span> <span class="keyword">extends</span> <span class="title">ICompute</span>.<span class="title">Stub</span> </span>&#123;</div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">add</span><span class="params">(<span class="keyword">int</span> a, <span class="keyword">int</span> b)</span> </span>&#123;</div><div class="line">        <span class="keyword">return</span> a + b;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li><code>SecurityCenterImpl.java</code></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> us.igrant.binderconnectpool;</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SecurityCenterImpl</span> <span class="keyword">extends</span> <span class="title">ISecurityCenter</span>.<span class="title">Stub</span> </span>&#123;</div><div class="line"></div><div class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">char</span> SECRET_CODE = <span class="string">'^'</span>;</div><div class="line"></div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">encrypt</span><span class="params">(String content)</span> </span>&#123;</div><div class="line">        <span class="keyword">char</span>[] chars = content.toCharArray();</div><div class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; chars.length; i++) &#123;</div><div class="line">            chars[i] ^= SECRET_CODE;</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">return</span> <span class="keyword">new</span> String(chars);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">decrypt</span><span class="params">(String password)</span> </span>&#123;</div><div class="line">        <span class="keyword">return</span> encrypt(password);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="连接池的接口"><a href="#连接池的接口" class="headerlink" title="连接池的接口"></a>连接池的接口</h2><ul>
<li><code>IBinderPool.aidl</code></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> us.igrant.binderconnectpool;</div><div class="line"></div><div class="line"><span class="keyword">import</span> android.os.IBinder;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">interface</span> <span class="title">IBinderPool</span> </span>&#123;</div><div class="line">    <span class="function">IBinder <span class="title">queryBinder</span><span class="params">(<span class="keyword">int</span> binderCode)</span></span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li><code>BinderPoolImpl.java</code>, 这里采用了 SparseArray 来存储 <code>{&#39; int &#39;:&#39; className &#39;}</code> 键值对，每一个不同的业务都由一个相应的整数值代表。</li>
</ul>
<blockquote>
<p><code>queryBinder</code> 方法会根据传入的整数值找到对应的类名，并且实例化（这里可以考虑加入缓存 IBinder 对象的机制）。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> us.igrant.binderconnectpool;</div><div class="line"></div><div class="line"><span class="keyword">import</span> android.os.IBinder;</div><div class="line"><span class="keyword">import</span> android.os.RemoteException;</div><div class="line"><span class="keyword">import</span> android.util.SparseArray;</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">BinderPoolImpl</span> <span class="keyword">extends</span> <span class="title">IBinderPool</span>.<span class="title">Stub</span> </span>&#123;</div><div class="line"></div><div class="line">    <span class="keyword">private</span> <span class="keyword">static</span> SparseArray&lt;Class&lt;? extends IBinder&gt;&gt; binderArray = <span class="keyword">new</span> SparseArray&lt;&gt;();</div><div class="line"></div><div class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> COMPUTE_BINDER_CODE = <span class="number">0</span>;</div><div class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> SECURITY_CENTER_BINDER_CODE = <span class="number">1</span>;</div><div class="line"></div><div class="line">    <span class="keyword">static</span> &#123;</div><div class="line">        binderArray.put(COMPUTE_BINDER_CODE, ComputeImpl.class);</div><div class="line">        binderArray.put(SECURITY_CENTER_BINDER_CODE, SecurityCenterImpl.class);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> IBinder <span class="title">queryBinder</span><span class="params">(<span class="keyword">int</span> binderCode)</span> <span class="keyword">throws</span> RemoteException </span>&#123;</div><div class="line">        Class binderClass = binderArray.get(binderCode);</div><div class="line">        <span class="keyword">if</span> (binderClass == <span class="keyword">null</span>) &#123;</div><div class="line">            <span class="keyword">return</span> <span class="keyword">null</span>;</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">try</span> &#123;</div><div class="line">            <span class="keyword">return</span> (IBinder) binderClass.newInstance();</div><div class="line">        &#125; <span class="keyword">catch</span> (InstantiationException e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">            <span class="keyword">return</span> <span class="keyword">null</span>;</div><div class="line">        &#125; <span class="keyword">catch</span> (IllegalAccessException e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">            <span class="keyword">return</span> <span class="keyword">null</span>;</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="唯一的一个-Service-返回的是连接池的-IBinder-对象"><a href="#唯一的一个-Service-返回的是连接池的-IBinder-对象" class="headerlink" title="唯一的一个 Service 返回的是连接池的 IBinder 对象"></a>唯一的一个 Service 返回的是连接池的 IBinder 对象</h2><ul>
<li><code>BinderPoolService.java</code></li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> us.igrant.binderconnectpool;</div><div class="line"></div><div class="line"><span class="keyword">import</span> android.app.Service;</div><div class="line"><span class="keyword">import</span> android.content.Intent;</div><div class="line"><span class="keyword">import</span> android.os.Binder;</div><div class="line"><span class="keyword">import</span> android.os.IBinder;</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">BinderPoolService</span> <span class="keyword">extends</span> <span class="title">Service</span> </span>&#123;</div><div class="line"></div><div class="line">    <span class="keyword">private</span> Binder mBinderPool = <span class="keyword">new</span> BinderPoolImpl();</div><div class="line"></div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> IBinder <span class="title">onBind</span><span class="params">(Intent intent)</span> </span>&#123;</div><div class="line">        <span class="keyword">return</span> mBinderPool;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="Activity-中的远程调用"><a href="#Activity-中的远程调用" class="headerlink" title="Activity 中的远程调用"></a>Activity 中的远程调用</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">private</span> ServiceConnection connection = <span class="keyword">new</span> ServiceConnection() &#123;</div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onServiceConnected</span><span class="params">(ComponentName name, IBinder service)</span> </span>&#123;</div><div class="line">        IBinderPool iBinderPool = IBinderPool.Stub.asInterface(service);</div><div class="line">        <span class="keyword">try</span> &#123;</div><div class="line">            IBinder computeBinder = iBinderPool.queryBinder(BinderPoolImpl.COMPUTE_BINDER_CODE);</div><div class="line">            ICompute compute = ComputeImpl.asInterface(computeBinder);</div><div class="line">            <span class="keyword">int</span> result = compute.add(<span class="number">5</span>, <span class="number">7</span>);</div><div class="line">            Log.i(TAG, <span class="string">"onServiceConnected: result = "</span> + result);</div><div class="line">        &#125; <span class="keyword">catch</span> (RemoteException e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125;</div><div class="line">        <span class="keyword">try</span> &#123;</div><div class="line">            IBinder securityCenterBinder = iBinderPool.queryBinder(BinderPoolImpl.SECURITY_CENTER_BINDER_CODE);</div><div class="line">            ISecurityCenter securityCenter = SecurityCenterImpl.asInterface(securityCenterBinder);</div><div class="line">            String password = securityCenter.encrypt(<span class="string">"abc"</span>);</div><div class="line">            Log.i(TAG, <span class="string">"onServiceConnected: password = "</span> + password);</div><div class="line">            String content = securityCenter.decrypt(password);</div><div class="line">            Log.i(TAG, <span class="string">"onServiceConnected: content = "</span> + content);</div><div class="line">        &#125; <span class="keyword">catch</span> (RemoteException e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125;</div><div class="line">    &#125;</div></pre></td></tr></table></figure>
<p>运行结果</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">us.igrant.binderconnectpool I/MainActivity: onServiceConnected: result = 12</div><div class="line">us.igrant.binderconnectpool I/MainActivity: onServiceConnected: password = ?&lt;=</div><div class="line">/us.igrant.binderconnectpool I/MainActivity: onServiceConnected: content = abc</div></pre></td></tr></table></figure>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag">#Android</a>
          
            <a href="/tags/IPC/" rel="tag">#IPC</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/06/26/AndroidIPC学习笔记3/" rel="next" title="Android IPC 学习笔记 3 使用 ContentProvider, Socket 进行进程间通信">
                <i class="fa fa-chevron-left"></i> Android IPC 学习笔记 3 使用 ContentProvider, Socket 进行进程间通信
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/07/08/lifeCycleOfActivity/" rel="prev" title="Activity 知识点">
                Activity 知识点 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://ww1.sinaimg.cn/mw690/6e8939a6gw1f3g1u1mc6lj20hs0hsmxf.jpg"
               alt="Granton Zhuang" />
          <p class="site-author-name" itemprop="name">Granton Zhuang</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives/index.html">
              <span class="site-state-item-count">26</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">11</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#建立不同业务的-AIDL-接口"><span class="nav-number">1.</span> <span class="nav-text">建立不同业务的 AIDL 接口</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#接口的实现"><span class="nav-number">2.</span> <span class="nav-text">接口的实现</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#连接池的接口"><span class="nav-number">3.</span> <span class="nav-text">连接池的接口</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#唯一的一个-Service-返回的是连接池的-IBinder-对象"><span class="nav-number">4.</span> <span class="nav-text">唯一的一个 Service 返回的是连接池的 IBinder 对象</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Activity-中的远程调用"><span class="nav-number">5.</span> <span class="nav-text">Activity 中的远程调用</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Granton Zhuang</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  




  
  

  

  

  

</body>
</html>
